package br.com.iswe.gwt.manter.server;

import junit.framework.TestCase;

public class BasicGwrServiceControllerTest extends TestCase {

	public void testHashRoles(){
		
		//String role = "ROLE_TIPOOBJETOSEGURO_WRITE";
		String role = "ROLE";
		String roleHex = ""; 
		//aplica o hash sobre a role
		//String shaHex = org.apache.commons.codec.digest.DigestUtils.shaHex(role);
		//String md5Hex = org.apache.commons.codec.digest.DigestUtils.md5Hex(role);
		
		//Aplica algoritmo proprio apenas para reduzir od tamanho da String
		roleHex = tabaHex(role);
		
		
		assertTrue(roleHex.length() < role.length());
		
	}

	private String tabaHex(String role) {
		//Transforma a string em um valor decimal..
		StringBuilder stringLongValue = new StringBuilder("");
		char[] chars = role.toCharArray();
		for(char item : chars){
			stringLongValue.append( Character.getNumericValue(item) );
		}
		//valor numerico
		//Long longValue = new Long( stringLongValue.toString() );
		//enquanto o resultado da divisao foir maior q 10
		
		return null;
	}
	
	
}
